//
//  SKUDefultUserImageNewV.m
//  ZITHER
//
//  Created by weixin on 2018/9/2.
//  Copyright © 2018年 weixn. All rights reserved.
//

#import "SKUDefultUserImageNewV.h"

@implementation SKUDefultUserImageNewV

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self defaultConfiguration] ;
        [self setUI];
        [self setMasonry];
    }
    return self;
}
-(void)defaultConfiguration
{
    
}
-(void)setUI
{
    
}
-(void)setMasonry
{
    
}
-(void)setModel:(skuDetailModel *)model
{
    _model = model;
    
    

    for (UIView *view in [self subviews]) {
        [view removeFromSuperview];
    }
    
    //j每组图片的数量
    for (int i =0 ; i<2; i++) {
        NSArray *arr = nil;
        
        if (i == 0) {
            arr =  model.userAvatarList;
            if (! arr) {
                arr = [[NSArray alloc]init];
                NSLog(@"");
            }
        }else{
            arr = model.bizPortraitList;
            if (! arr) {
                arr = [[NSArray alloc]init];
                NSLog(@"");
            }
        }
        
       
        UIScrollView *scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, i*100, kScreenW,100)];
        scrollview.bounces = NO;
        scrollview.showsHorizontalScrollIndicator = NO;
        scrollview.bounces = NO; // 默认为YES 取消设置NO
        // 当bounces属性为NO时，以下两个属性设置无效
        scrollview.alwaysBounceHorizontal = YES; // 水平方向弹簧效果
        scrollview.alwaysBounceVertical = YES; // 垂直方向弹簧效果
        scrollview.decelerationRate = 0.1; // 值域 0~1 值越小减速停止的时间越短
        scrollview.backgroundColor = [UIColor whiteColor];
        [self addSubview:scrollview];
     
        NSInteger index = 0 ;
        index = arr.count;
        if (index>10) {
            index = 10;
        }
        scrollview.contentSize = CGSizeMake(68*index+15,0);

        for (int j = 0; j<index; j++) {
            UIImageView * imageV = [[UIImageView alloc]initWithFrame:CGRectMake(j*68+15,35, 60,60)];
            [imageV setCornerRadiusWithRadius:5 isMasks:YES];
            imageV.backgroundColor = [UIColor whiteColor];
            imageV.contentMode = UIViewContentModeScaleAspectFill;
            
            NSString *str = [NSString stringWithFormat:@"%@%@",RootUrlImage,arr[j]];
            
            [imageV sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"watchSmale"]];
            
            [scrollview addSubview:imageV];
        }
        
        QMUILabel *lab = [[QMUILabel alloc]initWithFrame:CGRectMake(10,10+100*i, 100, 15)];
        lab.font = [UIFont systemFontOfSize:15];
        if (i==0) {
            lab.text = [NSString stringWithFormat:@"%@次用户询价",model.enquiryCount];
        }else{
            lab.text = [NSString stringWithFormat:@"%@次商家报价",model.offerCount];
        }
        
        [self addSubview:lab];
    }
    
}
@end
